// mytablemodel.h
#ifndef CTMAINTABLEMODEL_H
#define CTMAINTABLEMODEL_H

#include "precomp.h"
#include "publicstruct.h"

//#include <QAbstractTableModel>
//#include <QStringList>

class CtMainTableModel : public QAbstractTableModel
{
    Q_OBJECT
public:
    explicit CtMainTableModel(QObject *parent = nullptr);
    ~CtMainTableModel();

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
    QVariant verticalHeaderData(int section, int role = Qt::DisplayRole) const;

    void addData(const DnSummaryInfo &dnsi);
    void deleteData(const int row);
    void clearData();
    void updateRangeData(QModelIndex topLeftIndex,QModelIndex bottomRightIndex);
    int   findItemsIdxByDnId(const int dnid ) const ;
    void toggleAllSelected(bool checked);

private:
    QVector<DnSummaryInfo>  m_diVect;
    QStringList m_headList;
    QVector<bool> m_rowCheckedStates;
    bool m_isAllSelected;
signals:
    void dataCleared();
};

#endif // CTMAINTABLEMODEL_H
